package com.jiyun.service;

import com.jiyun.dao.ClassMapper;
import com.jiyun.dao.GradeMapper;
import com.jiyun.dao.StudentMapper;
import com.jiyun.entity.Class;
import com.jiyun.entity.Grade;
import com.jiyun.entity.Student;
import com.jiyun.vo.StudentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {

    @Autowired
    StudentMapper sm;
    @Autowired
    ClassMapper classMapper;
    @Autowired
    GradeMapper gradeMapper;

    public List<Student> findAll(){
        return sm.selectAll();
    }
    public Student findstudentById(Integer id){
        return sm.selectByPrimaryKey(id);
    }
    public List<StudentVo> findAll2(){
        return sm.findAll2();
    }
    public List<Grade> findGrade(){
        return gradeMapper.selectAll();
    }
    public List<Class> findClass(){
        return classMapper.selectAll();
    }

    public void  inster(Student student){
        sm.insert(student);
    }
    public void delete(int id){
        sm.deleteByPrimaryKey(id);
    }
    public void update(Student student){
        sm.updateByPrimaryKeySelective(student);
    }
}
